﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

/*=====================================================================
  This file is part of a Microsoft SQL Server Shared Source Application.
  Copyright (C) Microsoft Corporation.  All rights reserved.
 
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
======================================================= */

namespace Microsoft.SqlCommunity.FaultRetry
{
    /// <summary>
    /// This dialog is used to let the user know about any unsaved changes and allow them to take appropriate action.
    /// </summary>
    public partial class SaveChangesDialog : Window
    {
        public enum ChangesDisposition { Save, Discard, Cancel };  // The three options the user can pick from to deal with unsaved changes

        /// <summary>
        /// What the user has selected for how to respond to unsaved changes
        /// </summary>
        public ChangesDisposition DialogChangeDisposition { get; set; }
 
        /// <summary>
        /// Initialize the dialog
        /// </summary>
        public SaveChangesDialog()
        {
            InitializeComponent();
        }
        /// <summary>
        /// On load set the default disposition of the unsaved changes to Save.
        /// </summary>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DialogChangeDisposition = ChangesDisposition.Save;
        }

        /// <summary>
        /// Invoked when the user clicks on the Discard button.  Change the desired disposition of the unsaved data and return 
        /// to the caller.
        /// </summary>
        private void DiscardButton_Click(object sender, RoutedEventArgs e)
        {
            DialogChangeDisposition = ChangesDisposition.Discard;
            DialogResult = true;
        }

        /// <summary>
        /// Invoked when the user clicks on the Cancel button.  Change the desired disposition of the unsaved data and return
        /// to the caller.
        /// </summary>
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            DialogChangeDisposition = ChangesDisposition.Cancel;
            DialogResult = false;
        }
    }
}
